package ${package_name}.service;
import java.util.List;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cater.common.BaseEntity;
import com.cater.common.PageResult;
import com.cater.query.CommonQuery;
import com.cater.sys.service.BaseService;
import ${package_name}.dao.${table_name}Dao;
import ${package_name}.entity.${table_name};


/**
* 描述：${table_annotation} 服务实现层
* @author ${author}
* @date ${date}
*/
@Service
public class ${table_name}ServiceImpl implements BaseService<${table_name}, CommonQuery, String> {

    @Autowired
    ${table_name}Dao dao;
	
	@Override
	public PageResult<${table_name}> findPageResult(CommonQuery query) {
		PageResult<${table_name}> result = new PageResult<${table_name}>();
		result.setPage(query.getPage());
		result.setPageSize(query.getRows());
		int count = dao.findCount(query);
		int first = (query.getPage() - 1) * query.getRows();
		int max = query.getRows();
		List<${table_name}> list = dao.findList(query, first, max);
		result.setRows(list);
		result.setRecords(count);
		return result;
	}

	@Override
	public List<${table_name}> getAll() {
		return dao.getAll();
	}

	@Override
	public List<${table_name}> getAllCommon(CommonQuery query) {
		return dao.getAllCommon(query);
	}

	@Override
	public int save(${table_name} t) {
		return 0;
	}

	@Override
	public String saves(${table_name} t) {
		t.setId(UUID.randomUUID().toString().replaceAll("-", ""));
		dao.save(t);
		return t.getId();
	}

	@Override
	public void update(${table_name} t) {
		dao.update(t);
	}

	@Override
	public void delete(String id) {
		dao.delete(id);
	}

	@Override
	public ${table_name} getById(String id) {
		return dao.getById(id);
	}
}